
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height, user-scalable=no,initial-scale=1, minimum-scale=1, maximum-scale=1 ">
<link rel="stylesheet" type="text/css" href="{{static_url('css/public.css')}}">
<script type="text/javascript" src="{{static_url('js/zepto.min.js')}}"></script>
<script type="text/javascript" src="{{static_url('js/public.js')}}"></script>
<style type="text/css">
table{
    color: #767676;
    margin-top: 15px;
}
table td{padding-bottom: 10px;}
table a{color: #55AAFD!important;}
.divcenter{height: 550px;margin-top: -290px;}
</style>
<body>
    <div class="divcenter" >
        <form id="form" method="post" action="{{url('user/register')}}">
            <div class="form">
                <div class="text-center title">注 册</div>
                <table class="center" style="width: 90%">
                    <tr>
                        <td style="width: 80px;">登录名：</td>
                        <td><input type="text" class="full hcenter" name="name"></td>
                    </tr>
                    <tr>
                        <td>密码：</td>
                        <td><input type="password" class="full hcenter" id="p1" name="password"></td>
                    </tr>
                    <tr>
                        <td>确认密码：</td>
                        <td><input type="password" class="full hcenter" id="p2" name="password2"></td>
                    </tr>
                    <tr>
                        <td>手机：</td>
                        <td><input type="text" class="full hcenter" id="tel" name="tel"></td>
                    </tr>
                    <tr>
                        <td>验证码：</td>
                        <td>
                            <input type="text" class="full hcenter" id="code" name="code" style="width: 43%;float: left;">
                            <input type="button" class="full hcenter" id="getcode" name="" value="获取验证码" style="width: 48%;">
                        </td>
                    </tr>
                    <tr>
                        <td><a href="{{url('user/login')}}">已有账号</a></td>
                        <td><input type="submit" class="btn" value="下一步"></td>
                    </tr>
                </table>
            </div>
        </form>
    </div>
    <div class="palert" id="talert">
        <span id="tc">请输入用户名或密码</span>
        <input type="button" onclick="palert.close('#talert')" value="关闭">
    </div>
</body>
<script type="text/javascript">
    $('#form').on('submit', function(){
        if($('#name').val() == '' || $('#p1').val() == '' || $('#p2').val() == ''){
            $('#tc').html('请输入用户名或密码');
            palert.open('#talert');
            return false;
        }else if($('#p1').val() != $('#p2').val()){
            $('#tc').html('两次密码不一致');
            palert.open('#talert');
            return false;
        }else if($('#Fname').val() == '' || $('#Fno').val() == '' || $('#Fdorm_id').val() == '' || $('#Froom').val() == '' || $('#Ftel').val() == '' || $('#Fage').val() == ''){
            $('#tc').html('请输入完整的信息');
            palert.open('#talert');
            return false;
        }
        // alert($('#Fname').val())
        return true;
    });
    $('#getcode').click(function(){
        if(xcode){
            if($('#tel').val()!=''){
                url = '/user/register/getcode?tel=' + $('#tel').val();
                $.get(url, function(data, status, xhr){ 
                    if(data=='0'){
                        alert('短信发送成功');
                        settime('#getcode');
                    }else{
                        alert('短信发送失败');
                        alert(data);
                    }
                });
            }else{
                alert('请输入电话')
            }
        }
    });
    xcode = true;
    countdown = 60;
    function settime(val) { 
        if (countdown == 0) {
            $(val).val('免费获取验证码');
            countdown = 60;
            xcode = true;
        } else {
            xcode = false;
            $(val).val("重新发送(" + countdown + ")");
            countdown--;
        } 
        setTimeout(function() { 
            settime(val) 
        },1000) 
    } 
</script>
</html>